Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(database): add database user password update route #373

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

curzolapierre
Copy link
Member

@curzolapierre curzolapierre commented Feb 9, 2024

@curzolapierre curzolapierre self-assigned this Feb 9, 2024
@curzolapierre curzolapierre force-pushed the fix/cli/642/database_user_update branch 2 times, most recently from 7cacf91 to 6b3af9f Compare February 20, 2024 17:18
@curzolapierre curzolapierre marked this pull request as ready for review February 20, 2024 17:19
@curzolapierre curzolapierre force-pushed the fix/cli/642/database_user_update branch from 6b3af9f to 56333a3 Compare February 21, 2024 08:41
Copy link

@curzolapierre curzolapierre requested a review from ipfaze February 21, 2024 09:34
databases.go Outdated
DatabaseUser DatabaseUpdateUserParam `json:"database_user"`
}

// DatabaseUpdateUser updates an user to the given database addon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: it's "a user" not "an user"

databases.go Outdated
}

// DatabaseUpdateUser updates an user to the given database addon
func (c *Client) DatabaseUpdateUser(ctx context.Context, app, addonID, username string, user DatabaseUpdateUserParam) (DatabaseUser, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: the "user" variable is misleading in this case. It could be better to name it like "databaseUserParams" WDYT?

databases.go Outdated
}
err := c.DBAPI(app, addonID).SubresourceUpdate(ctx, "databases", addonID, "users", username, payload, &res)
if err != nil {
return res.DatabaseUser, errors.Wrapf(ctx, err, "create a user on database %s", addonID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: it should be "update a user" right?

@curzolapierre curzolapierre force-pushed the fix/cli/642/database_user_update branch from 56333a3 to c2015d2 Compare February 21, 2024 15:25
@curzolapierre curzolapierre requested a review from ipfaze February 21, 2024 15:25
Copy link
Contributor

@ipfaze ipfaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not directly related but can you fix the typo here:
"esource" --> "resource"

SubresourceUpdate(rctx context.Context, esource, resourceID, subresource, id string, payload, data interface{}) error

payload := databaseUpdateUserPayload{
DatabaseUser: databaseUserParams,
}
err := c.DBAPI(app, addonID).SubresourceUpdate(ctx, "databases", addonID, "users", username, payload, &res)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: "databases" and "users" shouldn't be constants?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, but IMO I prefer to see what is the route by seeing the string "databases".

But indeed it leaves room for potential manual errors.

However I think we should make this consistent with all other packages too.
It should be a dedicated issue I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you are right it should be a dedicated issue.
Can you create one for that please 🙏

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here: #375

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! ❤️

Copy link
Member Author

@curzolapierre curzolapierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"esource" --> "resource"

Nice catch ;)

payload := databaseUpdateUserPayload{
DatabaseUser: databaseUserParams,
}
err := c.DBAPI(app, addonID).SubresourceUpdate(ctx, "databases", addonID, "users", username, payload, &res)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, but IMO I prefer to see what is the route by seeing the string "databases".

But indeed it leaves room for potential manual errors.

However I think we should make this consistent with all other packages too.
It should be a dedicated issue I think.

@curzolapierre curzolapierre requested a review from ipfaze February 21, 2024 16:35
Copy link
Contributor

@ipfaze ipfaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@curzolapierre curzolapierre merged commit c8f2b1e into master Feb 22, 2024
2 checks passed
@curzolapierre curzolapierre deleted the fix/cli/642/database_user_update branch February 22, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants